﻿using System.Windows.Controls;
using Renren.Helpers;
using Renren.ViewModels;

namespace Renren.Controls
{
    public partial class HeaderBox : UserControl
    {
        static public bool ReactEvent { get; set; }

        private IHeaderViewModel HeaderView
        {
            get { return (IHeaderViewModel)DataContext; }
        }

        public HeaderBox()
        {
            if (!ReactEvent)
            {
                ReactEvent = true;
            }
            InitializeComponent();
            ReactEvent = true;
            this.HeadPhoto.Tap += (s, e) => this.Goto("UserPage", HeaderView.UserId);
            this.NameField.Tap += (s, e) => this.Goto("UserPage", HeaderView.UserId);
        }

        private void Goto(string page, object arg)
        {
            if (ReactEvent)
            {
                this.NavigateTo(page, arg);
            }
        }
    }
}
